package hl.demosample.ui.adapter

import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import hl.demosample.R
import hl.demosample.app.ext.setAdapterAnimation
import hl.demosample.app.util.SettingUtil
import hl.demosample.data.model.bean.WelfareData

/**
 *    Author : hongliang
 *    E-mail : 13717858152@163.com
 *    Date   : 2021/2/2211:13 AM
 *    Desc   :
 *    Version: 1.0.0
 *
 */
class WelfareAdapter(data: ArrayList<WelfareData.ResultsBean>) :
    BaseQuickAdapter<WelfareData.ResultsBean, BaseViewHolder>(R.layout.welfare_item, data) {

    init {
        setAdapterAnimation(SettingUtil.getListMode())
    }

    override fun convert(holder: BaseViewHolder, item: WelfareData.ResultsBean) {
        item.run {
            Glide.with(context).load(item.url)
                .transition(DrawableTransitionOptions.withCrossFade(200))
                .apply(RequestOptions().placeholder(R.mipmap.ic_launcher))
                .into(holder.getView(R.id.imageView))
        }
    }
}